package com.example.administrator.copyqq;

import android.os.Bundle;
import android.support.design.widget.BottomSheetDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.flipboard.bottomsheet.BottomSheetLayout;

import butterknife.ButterKnife;
import butterknife.InjectView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {


    @InjectView(R.id.button)
    Button button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.inject(this);
        button.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        RecyclerView rvContent= (RecyclerView) getLayoutInflater().from(this).inflate(R.layout.item,null);
        rvContent.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false));
        rvContent.setItemAnimator(new DefaultItemAnimator());
        rvContent.setAdapter(new MyRecycleViewAdapter());
        BottomSheetDialog dialog = new BottomSheetDialog(this);
        dialog.setContentView(rvContent);
        dialog.show();
    }

    class MyRecycleViewAdapter extends RecyclerView.Adapter {

        @Override
        public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            LinearLayout layout = (LinearLayout) View.inflate(parent.getContext(), R.layout.bottom, null);
            return new Myholder(layout);
        }

        @Override
        public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
            Myholder myholder = (Myholder) holder;
            myholder.bottom_tv.setText("hello ,Sb Ke"+position);
        }

        @Override
        public int getItemCount() {
            return 10;
        }
    }

    class Myholder extends RecyclerView.ViewHolder {

        public TextView bottom_tv;

        public Myholder(View itemView) {
            super(itemView);
            bottom_tv = (TextView) itemView.findViewById(R.id.bottom_tv);
        }
    }
}
